<?php
/**
 * 清除缓存，包括图片缓存及运行缓存
 * @author Mortimer He <mortimerhe@163.com>
 */
namespace Manage\Controller;
class CacheController extends CommonController{
	public function index(){
		$runtime_size=format_bytes(getDirSize(RUNTIME_PATH));
		$image_cache_size=format_bytes(getDirSize(C('IMAGE_CACHE')));
		$this->assign('runtime_size',$runtime_size);
		$this->assign('image_cache_size',$image_cache_size);
		$this->display();
	}
	public function clear($type=1){
		$dir='';
		$title=L('text_runtime_cache');
		switch ($type) {
			case 1:
				$dir=RUNTIME_PATH;
				break;
			case 2:
				//图片缓存
				$dir=C('IMAGE_CACHE');
				$title=L('text_image_cache');
				break;
			default:
				$dir=RUNTIME_PATH;
				break;
		}
		rmdirs($dir);
		session('success',L('success_clear').$title);
		$this->redirect('index');
	}
}